package com.bicycle.rentalsystem.servelt.user;

import com.bicycle.rentalsystem.pojo.admin.Bicycle;
import com.bicycle.rentalsystem.service.admin.BicycleService;
import com.bicycle.rentalsystem.service.impl.admin.BicycleServiceImpl;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/user/rent")
public class RentServlet extends HttpServlet {
    BicycleService bicycleService=new BicycleServiceImpl();

    protected void list(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.查询全部自行车
        List<Bicycle> bike = bicycleService.searchBicycles();
        //2.自行车保存到request域中
        req.setAttribute("rbike",bike);
        //3.请求转发
        req.getRequestDispatcher("userRent.jsp").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        list(req,resp);
    }

}
